/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.winni.Controller;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Sushant
 */
@WebServlet(name = "addItemServlet", urlPatterns = {"/addItemServlet"})
public class addItemServlet extends HttpServlet {

    /**
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
     * methods.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
     protected void service(HttpServletRequest req,HttpServletResponse res)
        throws IOException,ServletException{
	System.out.println("service()");
	//1.collect the data
	String id=req.getParameter("id");
	String fn=req.getParameter("fname");
	String ph=req.getParameter("phone");
	String des=req.getParameter("desc");
	String pr=req.getParameter("price");
	String sto=req.getParameter("stock");
	//2.process 
	//store in db
	String msg="Your Enquiry Has been added successfully";
        System.out.println("ID:"+id);
	System.out.println("Full name:"+fn);
	System.out.println("Phone no:"+ph);
	System.out.println("Description:"+des);
	System.out.println("Price:"+pr);
	System.out.println("Stock:"+sto);
	res.setContentType("text/html");
	PrintWriter out=res.getWriter();
	out.println("<h1>Dhawala Online Solutions Private Limited</h1>");
	out.println("<h1>"+msg+"</h1>");
       out.println("<h1>Email ID:"+id);
       out.println("<h1>Full name:"+fn);
   
    out.println("<h1>Phone No:"+ph);
    out.println("<h1>Description:"+des);
    out.println("<h1>Price:"+pr);
    out.println("<h1>Stock:"+sto);
}
public void destroy(){
	System.out.println("destroy()");
}
	}

			











    



